﻿using Microsoft.AspNetCore.Identity;
using Shop.Application.UserAdmin.Dto;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Shop.Application.UserAdmin
{
   public class GetUserByUserName
    {
        private UserManager<IdentityUser> _userManager;

        public GetUserByUserName(UserManager<IdentityUser> userManager)
        {
            _userManager = userManager;
        }

        public async Task<UserDto> Do(string name)
        {
            var user = await _userManager.FindByNameAsync(name);
            return new UserDto
            {
                UserID = user.Id,
                UserName = user.UserName,
                Email = user.Email,
                PhoneNumber = user.PhoneNumber
            };
        }
    }
}
